package lumingweihua.future.cn.lumingweihua.network;

import android.view.View;
import android.view.ViewGroup;

import in.srain.cube.views.ptr.PtrClassicFrameLayout;
import lumingweihua.future.cn.lumingweihua.R;

/**
 * Author       zhusx
 * Email        327270607@qq.com
 * Created      2017/4/21 12:00
 */

public class RefreshLayout extends PtrClassicFrameLayout {

    public RefreshLayout(ViewGroup recyclerView) {
        super(recyclerView.getContext());
        ViewGroup.LayoutParams lp = recyclerView.getLayoutParams();
        ViewGroup group = (ViewGroup) recyclerView.getParent();
        int index = group.indexOfChild(recyclerView);
        group.removeView(recyclerView);
        group.addView(this, index, lp);
        addView(recyclerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        setResistance(1.7f);
        setRatioOfHeaderHeightToRefresh(1.2f);
//        setDurationToClose(200);
//        setDurationToCloseHeader(1000);
//        setPullToRefresh(true);
//        setKeepHeaderWhenRefresh(true);
        setHeaderView(View.inflate(getContext(), R.layout.refresh_top_item2, null));
        onFinishInflate();
    }
}
